﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;

namespace HeadFirest._08.IteratorAndComponet._01.Menus
{
    public class Menu : Menucomponent
    {

        ArrayList _menuComponets = new ArrayList();
        string _name;
        string _description;

        public Menu(string name, string description)
        {
            _name = name ?? throw new ArgumentNullException(nameof(name));
            _description = description ?? throw new ArgumentNullException(nameof(description));
        }

        public override void Add(Menucomponent component)
        {
            _menuComponets.Add(component);
        }

        public override void Remove(Menucomponent component)
        {
            _menuComponets.Remove(component);
        }

        public override Menucomponent GetChild(int i)
        {
           return _menuComponets[i] as Menucomponent;
        }

        public override string GetDescription()
        { 
        
            return _description;
        }

        public override string GetName()
        {
            return _name;
        }
      

        public override void Print()
        {
            Console.WriteLine("\n"+GetName());
            Console.WriteLine(","+GetDescription());
            Console.WriteLine("---------------------");
            var interator = _menuComponets.GetEnumerator();
            if (interator.MoveNext()) 
            {
                (interator.Current as Menucomponent).Print(); ;

            }
            
        }
    }
}
